package com.atldy.commerce.service;

import brave.Tracer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-08-09 22:57
 * @Description：
 */
@Service
@Slf4j
public class SleuthService {

    @Autowired
    private Tracer tracer;

    public Map getTracer() {
        log.info("sleuth trace id [{}]", tracer.currentSpan().context().traceId());
        log.info("sleuth span id [{}]", tracer.currentSpan().context().spanId());
        Map<String, Object> result = new HashMap<>();
        result.put("sleuth trace id:",tracer.currentSpan().context().traceId());
        result.put("sleuth span id:",tracer.currentSpan().context().spanId());
        return result;
    }

}